package com.xframework.security.util;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
 * Created by xuning on 2017/3/4.
 */
@Component
@ConfigurationProperties(prefix = "security.wx")
public class WxConstant {

    public final static String WX_NOTIFY_URL = "https://www.dazongpai.com/redcube/controller/wx/pay/notify";

    public final static String WX_OPENID_ = "OPENID_";
    public final static String WX_GLOBAL_ACCESS_TOKEN_ = "WX_GLOBAL_ACCESS_TOKEN_";
    public final static String WX_JS_API_TICKET_ = "WX_JS_API_TICKET_";

    // 用户同意授权,获取code
    public final static String WX_AUTHORIZE_URL = "https://open.weixin.qq.com/connect/oauth2/authorize?appid={0}&redirect_uri={1}&response_type=code&scope=snsapi_userinfo&state=123#wechat_redirect";

    // 凭证获取（GET）
    public final static String WX_WEB_ACCESS_TOKEN_URL = "https://api.weixin.qq.com/sns/oauth2/access_token?appid={0}&secret={1}&code={2}&grant_type=authorization_code";
    public final static String WX_GLOBAL_ACCESS_TOKEN_URL = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={0}&secret={1}";
    public final static String WX_JS_API_TICKET_URL = "https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token={0}&type=jsapi";
    public final static String WX_SEND_URL = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token={0}";
    public final static String WX_TEMPLATE_URL = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token={0}";

    public final static String WX_AUTH_URL = "https://api.weixin.qq.com/sns/auth?access_token={0}&openid={1}";//{ "errcode":0,"errmsg":"ok"}
    // 拉去用户信息url
//    public final static String WX_USERINFO_URL = "https://api.weixin.qq.com/sns/userinfo?access_token={0}&openid={1}&lang=zh_CN";
    public final static String WX_USERINFO_URL = "https://api.weixin.qq.com/cgi-bin/user/info?access_token={0}&openid={1}";
    public final static String WX_KEY = "oDqSkIvD6WFCDIRockZk8IJ0Q2ccFZLR";
    public final static String WX_MCHID = "1359090902";
    public final static String WX_PAY_CERT_PATH = "/opt/apache-tomcat-8.5.15/conf/scratch-wx-api-cert.p12";

    public final static String OPENID = "openid";
    public final static String ACCESS_TOKEN = "access_token";
    public final static String TICKET = "ticket";

    public final static String WX_EncodingAESKey = "kJPRiSk9wziZhVQy4P6Hfz3OCwNjMXA9goh1hsitbuu";

    public static String wxAppId = "wxb260cb11fcdb2b4b";

    public static String wxAppSecret = "f5e12765c3efa3c2b20cf36292b6d513";

    // 用户同意授权,回调url /wx/pay/notify
    public static String wxDomainUrl = "https://";

    public static String wxRedirectUrl = "/controller/security/WxToken";


    public void setWxAppId(String wxAppId) {
        WxConstant.wxAppId = wxAppId;
    }

    public void setWxAppSecret(String wxAppSecret) {
        WxConstant.wxAppSecret = wxAppSecret;
    }

    public void setWxDomainUrl(String wxDomainUrl) {
        WxConstant.wxDomainUrl = wxDomainUrl;
    }

    public void setWxRedirectUrl(String wxRedirectUrl) {
        WxConstant.wxRedirectUrl = wxRedirectUrl;
    }
}
